<?php


	if (isset($_GET["weeknr"]) && isset($_GET["basis"]))
	{
		
		require_once("../../dbconn.php");
		
		$weeknr = $_GET["weeknr"];
		
		$QUERY = "
			INSERT INTO studieuur (id, uur, dag, week) 
			VALUES (NULL, '3', 'Di', '$weeknr');";
		$RESULT = mysql_query($QUERY) or die('<b style="color: red; font-size: 25px;">Error!</b><br /><br />' . mysql_error());
		//echo "query = $QUERY <br /><br />week toegevoegd!";
	}
	else
	{

		require_once("dbconn.php");

		$QUERY = "
			SELECT DISTINCT week 
			FROM studieuur
		";
		$RESULT = mysql_query($QUERY) or die('<b style="color: red; font-size: 25px;">Error!</b><br /><br />' . mysql_error());
		//echo "query = $QUERY <br /><br />";
		$rows = mysql_num_rows($RESULT);
		
		$weeknr = mysql_result($RESULT, $rows - 1, "week");
		$weeknr >= 52 ? $weeknr = 1 : $weeknr++;

?><form id="toevoeger" method="get" action="funcs/week/add.php" target="_blank">
	<table cellspacing="0" align="left" valign="top">
		<tr>
			<td colspan="<?php print($DBC->rows); ?>">
				<h1>Voeg toe: week</h1>
			</td>
		</tr>
		<tr style="vertical-align: top;">
			<td>
				nr:
			</td>
			<td>
				<input type="text" name="weeknr" style="display: block; width: 100px;" value="<?php print($weeknr); ?>" />
			</td>
		</tr>
		<tr style="vertical-align: top;" height="100">
			<td>
				basis:
			</td>
			<td>
				<select name="basis" style="display: block; width: 100px;">
					<option>b1</option>
					<option>b2</option>
				</select>
			</td>
		</tr>
		<tr style="vertical-align: top;">
			<td colspan="2" align="center">
				<a onclick="document.getElementById('toevoeger').submit();" class="bigbutton">voeg&nbsp;toe!</a>
			</td>
		</tr>
	</table>
</form>
<?



	}
	
?>